// import { Notice } from 'iview'
import { Notification,MessageBox } from 'element-ui' ;

/**
 * 处理api错误约定
 * { code, data, message }
 * @param {object} result
 */
export default function handle(result) {
    // if (isObject(result)) {
    //   return result
    // }
    
    // console.log(666,result)
    if (typeof result !== 'object') {
        return result
    }

    // 此处处理和后端约定非正常返回状态
    if (result.code !== undefined && result.code) {
        
        if(result.code==10){
	    		MessageBox.confirm(`服务授权已到期,请重新授权`, "授权过期", {
		        confirmButtonText: "确定",
		        cancelButtonText: "取消",
		        type: "warning"
		      }).then(() => {
		       
		      });
	    	}else if(result.code==-2){
	    		window.location.href = window.loginUrl;
	    	}
	    	else{
	    		Notification.warning({ 
	        	//title: '请求错误：', 
	        	message: result.message ,
	        })
	    	}
	    	
    }

    return result
}
